<html>
<head><meta charset="utf-8"><title>SEGFAULT on Alpine Docker · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html">SEGFAULT on Alpine Docker</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="220828944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220828944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220828944">(Dec 23 2020 at 21:28)</a>:</h4>
<p>I have a strange issue where I could use some help. I have a rust CLI tool that is SEGFAULTING when running in an Alpine Docker image. Running it as part of a Ubunut Docker Image seem to be fine. I've compiled it with the <code>rust:alpine</code> base image and then use <code>alpine:latest</code> as runtime image. Any idea what the cause could be. I've tried running valgrand against the release binary and it shows:</p>
<div class="codehilite"><pre><span></span><code>==29== Jump to the invalid address stated on the next line
==29==    at 0x0: ???
==29==    by 0x2C52CA: &lt;core::future::from_generator::GenFuture&lt;T&gt; as core::future::future::Future&gt;::poll (in /usr/local/bin/rust-release)
==29==    by 0x2C2A92: std::sys_common::backtrace::__rust_begin_short_backtrace (in /usr/local/bin/rust-release)
==29==    by 0x2C198B: core::ops::function::FnOnce::call_once{{vtable-shim}} (in /usr/local/bin/rust-release)
==29==    by 0x303CC9: call_once&lt;(),FnOnce&lt;()&gt;&gt; (boxed.rs:1042)
==29==    by 0x303CC9: call_once&lt;(),alloc::boxed::Box&lt;FnOnce&lt;()&gt;&gt;&gt; (boxed.rs:1042)
==29==    by 0x303CC9: std::sys::unix::thread::Thread::new::thread_start (thread.rs:87)
==29==    by 0x34250D: start (in /usr/local/bin/rust-release)
==29==  Address 0x0 is not stack&#39;d, malloc&#39;d or (recently) free&#39;d
</code></pre></div>



<a name="220828986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220828986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220828986">(Dec 23 2020 at 21:29)</a>:</h4>
<p>it would help to compile with debug symbols, that backtrace isn't super useful</p>



<a name="220829521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220829521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220829521">(Dec 23 2020 at 21:36)</a>:</h4>
<p>And that stack... is in a future... without showing any frames for the corresponding executor. Odd.</p>



<a name="220829569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220829569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220829569">(Dec 23 2020 at 21:37)</a>:</h4>
<p>yeah, I've found the backtraces available without debug info are really awful</p>



<a name="220829585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220829585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220829585">(Dec 23 2020 at 21:37)</a>:</h4>
<p>the compiler has the same issue, it will just skip 10 stack frames here and there lol</p>



<a name="220829589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220829589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220829589">(Dec 23 2020 at 21:37)</a>:</h4>
<p>I think it has something to do with inlining</p>



<a name="220829810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220829810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220829810">(Dec 23 2020 at 21:40)</a>:</h4>
<p>Like I said the strange thing is the same code runs fine on MacOS. And when I compile a Linux binary on Debian jessie and running inside a Ubuntu image. But let me try creating a debug binary on alpine and run that</p>



<a name="220829843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220829843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220829843">(Dec 23 2020 at 21:41)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker/near/220829589">said</a>:</p>
<blockquote>
<p>I think it has something to do with inlining</p>
</blockquote>
<p>most likely. without debuginfo, inlined functions don't show up at all.</p>



<a name="220829932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220829932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220829932">(Dec 23 2020 at 21:42)</a>:</h4>
<p>Ah ok now I get this with valgrind</p>
<div class="codehilite"><pre><span></span><code>==12== 2 errors in context 1 of 1:
==12== Jump to the invalid address stated on the next line
==12==    at 0x0: ???
==12==    by 0x44AFF9: openssl::ssl::SslMethod::tls (mod.rs:314)
==12==    by 0x43FF55: native_tls::imp::TlsConnector::new (openssl.rs:257)
==12==    by 0x4410D7: native_tls::TlsConnectorBuilder::build (lib.rs:423)
==12==    by 0x2A0237: reqwest::connect::Connector::new_default_tls (connect.rs:167)
==12==    by 0x2992BC: reqwest::async_impl::client::ClientBuilder::build (client.rs:226)
==12==    by 0x2DFBB4: reqwest::blocking::client::ClientHandle::new::{{closure}}::{{closure}} (client.rs:778)
==12==    by 0x2BE329: &lt;core::future::from_generator::GenFuture&lt;T&gt; as core::future::future::Future&gt;::poll (mod.rs:80)
==12==    by 0x3B4A94: tokio::runtime::basic_scheduler::BasicScheduler&lt;P&gt;::block_on::{{closure}}::{{closure}} (basic_scheduler.rs:131)
==12==    by 0x387EEA: tokio::coop::with_budget::{{closure}} (coop.rs:127)
==12==    by 0x21CA04: std::thread::local::LocalKey&lt;T&gt;::try_with (local.rs:272)
==12==    by 0x21C5AD: std::thread::local::LocalKey&lt;T&gt;::with (local.rs:248)
==12==  Address 0x0 is not stack&#39;d, malloc&#39;d or (recently) free&#39;d
</code></pre></div>



<a name="220829963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220829963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220829963">(Dec 23 2020 at 21:43)</a>:</h4>
<p>weird that all the file paths have been stripped</p>



<a name="220829976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220829976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220829976">(Dec 23 2020 at 21:43)</a>:</h4>
<p>hmm do you have the openssl C library installed on alpine?</p>



<a name="220830080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830080">(Dec 23 2020 at 21:44)</a>:</h4>
<p>Should be. I run <code> apk --no-cache add openssl</code> just to be sure but the segfault is the same</p>



<a name="220830112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830112">(Dec 23 2020 at 21:45)</a>:</h4>
<p>And wouldn't it throw me an error when starting the application in case openssl would be missing?</p>



<a name="220830144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830144">(Dec 23 2020 at 21:45)</a>:</h4>
<p>well I don't trust anything with dynamic linking to give useful errors :P</p>



<a name="220830159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830159">(Dec 23 2020 at 21:45)</a>:</h4>
<p>how did you build this binary? was it cross compiled?</p>



<a name="220830214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830214">(Dec 23 2020 at 21:46)</a>:</h4>
<p>This is the Dockerfile that builds and runs it:</p>
<div class="codehilite"><pre><span></span><code>FROM rust:alpine as builder

RUN apk add --no-cache \
    openssl-dev \
    libc-dev

ENV USER=root
RUN cargo new --bin rust-release
WORKDIR ./rust-release
COPY Cargo.toml Cargo.lock ./

RUN cargo build --release

RUN rm -Rf ./target/release/deps/rust_release*
COPY ./src/ ./src/
RUN cargo build --release
RUN cargo build

FROM alpine:latest
COPY --from=builder /rust-release/target/debug/rust-release /usr/local/bin
CMD [&quot;rust-release&quot;, &quot;-h&quot;]
</code></pre></div>



<a name="220830263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830263">(Dec 23 2020 at 21:47)</a>:</h4>
<p>you have openssl on the builder but not the final image</p>



<a name="220830271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830271">(Dec 23 2020 at 21:47)</a>:</h4>
<p>openssl is dynamically linked, you need it in the final image as well</p>



<a name="220830279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830279">(Dec 23 2020 at 21:47)</a>:</h4>
<p>(I think? not sure how openssl-sys does it)</p>



<a name="220830290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830290">(Dec 23 2020 at 21:47)</a>:</h4>
<p>So in theory in both cases it should use an alpine based OS. I did install it manually<br>
and rerun the command.</p>



<a name="220830306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830306">(Dec 23 2020 at 21:48)</a>:</h4>
<p>hmm, ok</p>



<a name="220830349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830349">(Dec 23 2020 at 21:48)</a>:</h4>
<p>not sure then, I'd ask the openssl maintainers</p>



<a name="220830418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830418">(Dec 23 2020 at 21:49)</a>:</h4>
<p>I also checked rust:alpine should be based on alpine <code>3.12</code> and alpine latest is <code>3.12</code> so that should be fine as well.</p>



<a name="220830422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830422">(Dec 23 2020 at 21:49)</a>:</h4>
<p>but I suspect it's related to having two different images</p>



<a name="220830442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830442">(Dec 23 2020 at 21:50)</a>:</h4>
<p>does it work with only a single image?</p>



<a name="220830485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830485">(Dec 23 2020 at 21:50)</a>:</h4>
<p>hmm I can try it (even though its not considered best practice)</p>



<a name="220830536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830536">(Dec 23 2020 at 21:51)</a>:</h4>
<p>tried it and no. Same segfault.</p>



<a name="220830553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830553">(Dec 23 2020 at 21:51)</a>:</h4>
<p>oh interesting</p>



<a name="220830554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830554">(Dec 23 2020 at 21:51)</a>:</h4>
<p>that's really strange then</p>



<a name="220830636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830636">(Dec 23 2020 at 21:52)</a>:</h4>
<p>but it's definitely related to FFI somehow, this is the line going wrong: <a href="https://docs.rs/openssl/0.10.31/src/openssl/ssl/mod.rs.html#313-315">https://docs.rs/openssl/0.10.31/src/openssl/ssl/mod.rs.html#313-315</a></p>



<a name="220830786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830786">(Dec 23 2020 at 21:54)</a>:</h4>
<p>I am gonna try using the debian image instead. Lets see if its alpine related or not (even though given that its officially provided I would assume it should work)</p>



<a name="220830857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220830857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220830857">(Dec 23 2020 at 21:56)</a>:</h4>
<p>if it works on ubuntu I would expect it to work on debian</p>



<a name="220831212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831212">(Dec 23 2020 at 22:00)</a>:</h4>
<p>Alpine is weird like that</p>



<a name="220831272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831272">(Dec 23 2020 at 22:01)</a>:</h4>
<p>MUSL doesn't support loading libraries dynamically unless you statically link to MUSL</p>



<a name="220831343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831343">(Dec 23 2020 at 22:02)</a>:</h4>
<p>But Rust links the C library by default, so you won't be able to call dlopen</p>



<a name="220831415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831415">(Dec 23 2020 at 22:03)</a>:</h4>
<p>Yeah debian is working after installing openssl. But it also shows an error initially: ```rust-release: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory</p>
<div class="codehilite"><pre><span></span><code>Before I installed openssl
</code></pre></div>



<a name="220831421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831421">(Dec 23 2020 at 22:03)</a>:</h4>
<p>I think there's a flag to change that, but I would avoid Alpine for anything with C FFI or where performance matters.</p>



<a name="220831472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831472">(Dec 23 2020 at 22:04)</a>:</h4>
<p>You probably need libssl-dev, that's normal</p>



<a name="220831495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831495">(Dec 23 2020 at 22:04)</a>:</h4>
<p>Interesting. So you recommend not to use alpine for rust as a runtime?</p>



<a name="220831521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831521">(Dec 23 2020 at 22:05)</a>:</h4>
<p>For anything, not only Rust</p>



<a name="220831527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831527">(Dec 23 2020 at 22:05)</a>:</h4>
<p>Oh, look: <a href="https://users.rust-lang.org/t/sigsegv-with-program-linked-against-openssl-in-an-alpine-container/52172/3">https://users.rust-lang.org/t/sigsegv-with-program-linked-against-openssl-in-an-alpine-container/52172/3</a></p>



<a name="220831602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831602">(Dec 23 2020 at 22:06)</a>:</h4>
<p>E.g. <a href="https://pythonspeed.com/articles/alpine-docker-python/">https://pythonspeed.com/articles/alpine-docker-python/</a></p>



<a name="220831629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831629">(Dec 23 2020 at 22:06)</a>:</h4>
<p>Interesting. I must have missed that when I was looking around.</p>



<a name="220831656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831656">(Dec 23 2020 at 22:07)</a>:</h4>
<p>Or <a href="https://superuser.com/questions/1219609/why-is-the-alpine-docker-image-over-50-slower-than-the-ubuntu-image">https://superuser.com/questions/1219609/why-is-the-alpine-docker-image-over-50-slower-than-the-ubuntu-image</a></p>



<a name="220831753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831753">(Dec 23 2020 at 22:08)</a>:</h4>
<p>I think more recent MUSL versions have a faster memory allocator, but I'm not sure it's worth the tradeoffs</p>



<a name="220831818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220831818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220831818">(Dec 23 2020 at 22:09)</a>:</h4>
<p>(unless it's something non-perf sensitive which doesn't call into C libraries, that's probably fine)</p>



<a name="220832417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220832417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220832417">(Dec 23 2020 at 22:17)</a>:</h4>
<p>Hmm makes sense. Guess I keep with with debian-slim for now. Not that this tool is in any way performance critical in itself.</p>



<a name="220832584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220832584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220832584">(Dec 23 2020 at 22:20)</a>:</h4>
<p>Alpine is a dynamically linked distro using MUSL, while Rust uses MUSL to fully statically link by default. Tying to mix those two things (by using a dynamically linked libssl-dev) causes things to blow up.</p>



<a name="220832602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220832602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220832602">(Dec 23 2020 at 22:21)</a>:</h4>
<p>If you want a fully static binary you shouldn't use the distro-provided libssl-dev, and probably shouldn't use the Alpine distro at all.</p>



<a name="220832696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220832696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220832696">(Dec 23 2020 at 22:22)</a>:</h4>
<p>if you are okay linking to musl dynamically then switch off the crt-static target feature iirc</p>



<a name="220832900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220832900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220832900">(Dec 23 2020 at 22:26)</a>:</h4>
<p>Interesting. I wonder if this shouldn't be the default mode when using the official rust alpine image for building a binary? Like my expectation as a new user would be if I use rust-alpine and then run <code>cargo build --release</code> that the binary can be just executed inside the build container as well as any other alpine container.</p>



<a name="220833009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220833009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220833009">(Dec 23 2020 at 22:28)</a>:</h4>
<p>It runs if it's pure Rust. If the app callls an unimplemented dlopen() or loads conflicting versions of a C library, that's not something the compiler can control</p>



<a name="220833164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220833164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220833164">(Dec 23 2020 at 22:31)</a>:</h4>
<p>I would argue that openssl / networking is a very common task. And its so common that it should ether work out of the box by the base image or it should be documented to keep an eye out for issues like this.</p>



<a name="220833308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220833308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220833308">(Dec 23 2020 at 22:34)</a>:</h4>
<p>If you make it work, <span class="user-mention" data-user-id="243558">@Steven Fackler</span>  might acccept a documentation  PR</p>



<a name="220833327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220833327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220833327">(Dec 23 2020 at 22:34)</a>:</h4>
<p>I would be worried that changing that default in the image would break the workflows of people that are using the alpine image to produce a fully static binary</p>



<a name="220833338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220833338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220833338">(Dec 23 2020 at 22:35)</a>:</h4>
<p>The openssl crate already has setup instructions for various platforms in the docs</p>



<a name="220834630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/SEGFAULT%20on%20Alpine%20Docker/near/220834630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Krauthan <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/SEGFAULT.20on.20Alpine.20Docker.html#220834630">(Dec 23 2020 at 22:58)</a>:</h4>
<p>Hmm I'll look into it. I guess I never seen the openssl docs as I am only interacting with <code>reqwest</code> and to my knowledge they don't mention anything about openssl/alpine in there docs. But thanks for all the help here.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>